package com.edu.exam.entity.grading.correction;

import com.edu.exam.enums.CorrectionAuditStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 修正审核实体类
 *
 * <p>所属模块：E-02 阅卷管理模块</p>
 * <p>对应数据库表：correction_audit</p>
 *
 * <p>记录成绩修正的审核过程信息，包括审核状态、审核意见、
 * 审核时间等关键信息。支持审核流程的全程跟踪和管理。</p>
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class CorrectionAudit {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull(message = "修正ID不能为空")
    @Column(name = "correction_id", nullable = false)
    private Long correctionId;

    @NotNull(message = "审核人ID不能为空")
    @Column(name = "auditor_id", nullable = false)
    private Long auditorId;

    @Size(max = 100, message = "审核人姓名长度不能超过100个字符")
    @Column(name = "auditor_name", length = 100)
    private String auditorName;

    @NotNull(message = "审核状态不能为空")
    @Enumerated(EnumType.STRING)
    @Column(name = "audit_status", nullable = false, length = 20)
    @Builder.Default
    private CorrectionAuditStatus auditStatus = CorrectionAuditStatus.PENDING;

    @Size(max = 1000, message = "审核意见长度不能超过1000个字符")
    @Column(name = "audit_comment", columnDefinition = "TEXT")
    private String auditComment;

    @NotNull(message = "审核时间不能为空")
    @CreatedDate
    @Column(name = "audit_time", nullable = false, updatable = false)
    private LocalDateTime auditTime;

    @Size(max = 500, message = "审核备注长度不能超过500个字符")
    @Column(name = "audit_remarks", length = 500)
    private String auditRemarks;

    @Column(name = "deleted", nullable = false)
    @Builder.Default
    private Boolean deleted = false;

    @LastModifiedDate
    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime;

    @Column(name = "create_user", nullable = false)
    private Long createUser;

    @Column(name = "update_user", nullable = false)
    private Long updateUser;


}
